<include file="common/header_lixin" title="个人中心" />
<style>
    .weui-label{
        color: #292828;
    }
</style>
<div class="page">
    <div class="page-hd">
        <div class="header bor-1px-b">
            <div class="header-left">
                <a href="javascript:history.go(-1)" class="left-arrow"></a>
            </div>
            <div class="header-title">兑换管理</div>
            <div class="header-right">
                <a href="#"></a>
            </div>
        </div>
    </div>

    <div class="page-bd">
        <!-- 页面内容-->
        <div class="card-flex tc">
            <div class="flex_item">
                <div class="fs26">可售余额 </div>
                <div class="fs42 font_number">{$user.balance}</div>
            </div>
            <div class="flex_item">
                <div class="fs26">矿池钱包 </div>
                <div class="fs42 font_number">{$user.miner}</div>
            </div>
        </div>
        <div class="weui-cells__title">
            兑换成矿池钱包
        </div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">可售余额</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="balance" type="number"  placeholder="1可售余额 = {$multiple}矿池资产">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">二级密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="paypwd"  type="password"  placeholder="请输入二级密码">
                </div>
            </div>
        </div>
        <div class="weui-btn-area">
            <a href="javascript:;"  onClick="exchange()"  class="weui-btn weui-btn_primary">确认兑换</a>
        </div>
    </div>
    <include file="common/footer_lixin"/>
</div>
<script>
    $(function() {
        FastClick.attach(document.body);
    });

    var ajax_status = false;
    function exchange()
    {
        if (ajax_status) {return ;}
        ajax_status = true;
        var balance = $('input[name="balance"]').val();
        var paypwd = $('input[name="paypwd"]').val();
        $.ajax({
            url : "/Acc/Mining/exchange",
            type:'post',
            dataType:'json',
            data:{'balance': balance,'paypwd':paypwd},
            success:function(data){
                if (data.code == 1) {
                    $.toast.prototype.defaults.duration = 1200;
                    $.toast(data.msg, function() {
                        window.location.reload();
                    });
                } else {
                    $.toptip(data.msg, 'error')
                }
                ajax_status = false;
            },
            error:function(){
                $.toptip('网络异常，请稍后再试')
            }
        })
    }
</script>
</body>
</html>